﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;
using Mbs.Net.Tcp;

namespace Mbs.Net
{
    public interface IClient:IServiceHost
    {
        HostInfo Info { get; }
        Socket Socket { get; }

        void Run();
    }

    public class Client : IClient
    {
        public Socket Socket { get; set; }
        public HostInfo Info { get; set; }
      

        #region IServiceHost Members

        public IServiceSender Sender { get; set; }

        public IServiceReceiver Receiver { get; set; }

        public void Run()
        {
            Receiver.Init(Info, this, Socket);
            Sender.Init(Info, this, Socket);
        }

        public void Close()
        {
            Socket.SafeClose();
        }

        #endregion
    }
}
